package com.sugon.lambda;

import java.util.Arrays;
import java.util.List;
import java.util.function.Consumer;

/**
 * 方法引用
 */
public class TestLambda2 {

    public static void main(String[] args) {

        List<String> stringList = Arrays.asList("User", "bb", "cc");
        stringList.forEach(new Consumer<String>() {
            @Override
            public void accept(String s) {
                System.out.println(s);
            }
        });
        stringList.forEach(s -> System.out.println(s));

        stringList.forEach(System.out::println);

    }

    I1 a1 = new I1() {
        public void test(User user) {
            user.method();
        }
    };

    I1 a2 = (User user) -> user.method();

    I1 a3 = User::method;

    I2 a4 = (User user, String b) -> user.method(b);

    I2 a5 = User::method;

    I3 a6 = (User user ,String b,String c)->user.method(b,c);

    I5 a7 = s -> Integer.parseInt(s);

    I5 a8 = Integer::parseInt;

    I5 a9 = s -> System.out.println(s);

    I5 a10 = System.out::println;


}


interface I1 {
    void test(User user);
}

interface I2 {
    void test(User user, String bb);
}

interface I3 {
    void test(User user, String bb, String cc);
}

interface I4{
    void test(String b, User user);
}

interface I5 {
    void test(String s);
}

class User {
    public void method() {
        System.out.println("sysout");
    }

    public void method(String s) {
    }

    public void method(String s1, String s2) {
    }
}


